visualizer
/
vendor
/
phpoffice
/
phpexcel
/
Documentation
/
Examples
/
Reading WorkBook Data
/
exampleWorkBookReader04.php
exampleWorkBookReader04.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.1.1, at vendor/phpoffice/phpexcel/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader04.php
| 1 | <?php |
| 2 | |
| 3 | error_reporting(E_ALL); |
| 4 | set_time_limit(0); |
| 5 | |
| 6 | date_default_timezone_set('Europe/London'); |
| 7 | |
| 8 | ?> |
| 9 | <html> |
| 10 | <head> |
| 11 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 12 | |
| 13 | <title>PHPExcel Reading WorkBook Data Example #04</title> |
| 14 | |
| 15 | </head> |
| 16 | <body> |
| 17 | |
| 18 | <h1>PHPExcel Reading WorkBook Data Example #04</h1> |
| 19 | <h2>Get a List of the Worksheets in a WorkBook</h2> |
| 20 | <?php |
| 21 | |
| 22 | /** Include path **/ |
| 23 | set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/'); |
| 24 | |
| 25 | /** PHPExcel_IOFactory */ |
| 26 | include 'PHPExcel/IOFactory.php'; |
| 27 | |
| 28 | |
| 29 | $inputFileType = 'Excel5'; |
| 30 | $inputFileName = './sampleData/example2.xls'; |
| 31 | |
| 32 | /** Create a new Reader of the type defined in $inputFileType **/ |
| 33 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
| 34 | /** Load $inputFileName to a PHPExcel Object **/ |
| 35 | $objPHPExcel = $objReader->load($inputFileName); |
| 36 | |
| 37 | |
| 38 | echo '<hr />'; |
| 39 | |
| 40 | echo 'Reading the number of Worksheets in the WorkBook<br />'; |
| 41 | /** Use the PHPExcel object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook */ |
| 42 | $sheetCount = $objPHPExcel->getSheetCount(); |
| 43 | echo 'There ',(($sheetCount == 1) ? 'is' : 'are'),' ',$sheetCount,' WorkSheet',(($sheetCount == 1) ? '' : 's'),' in the WorkBook<br /><br />'; |
| 44 | |
| 45 | echo 'Reading the names of Worksheets in the WorkBook<br />'; |
| 46 | /** Use the PHPExcel object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */ |
| 47 | $sheetNames = $objPHPExcel->getSheetNames(); |
| 48 | foreach($sheetNames as $sheetIndex => $sheetName) { |
| 49 | echo 'WorkSheet #',$sheetIndex,' is named "',$sheetName,'"<br />'; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | ?> |
| 54 | <body> |
| 55 | </html> |
| 56 |